package com.shf.collections;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import java.util.TreeSet;

/*
 * 
 */

public class Collection {

	public static void main(String[] args) {
//		iterator();
		hashMapAndSet();
	}
	
	public static void iterator(){
		ArrayList<Object> list = new ArrayList<>();
		list.add("a");
		list.add("d");
		list.add("c");
		Iterator<Object> iterator = list.iterator();
		while (iterator.hasNext()) {
			System.out.println(iterator.next());
		}
		
		
		
		
	}
	
	public static void hashMapAndSet(){
		HashMap<Object, Object> map = new HashMap<>();
		HashSet<Object> set = new HashSet<>();
		TreeSet<Object> treeSet = new TreeSet<>();

		map.put("1", 1);
		map.put("1", 2);
		map.put("2", 2);
		map.put("", "");
		map.put("",null );
		
		set.add(1);
		set.add(2);
		set.add(2);
		set.add(null);
		
		treeSet.add(1);
		treeSet.add(2);
		treeSet.add(2);

		Set<Object> keySet = map.keySet();
		Iterator<Object> iterator = keySet.iterator();
		
		while (iterator.hasNext()) {
			System.out.println(map.get(iterator.next())+"	this is map");
		}
		
		Iterator<Object> iterator2 = set.iterator();
		Iterator<Object> iterator3 = treeSet.iterator();
		while (iterator2.hasNext()) {
			System.out.println(iterator2.next()+"	this is set");
		}
		while (iterator3.hasNext()) {
			System.out.println(iterator3.next()+"	this is treeSet");
		}
		
	}
	
	
}
